﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MySqlQuery : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            try {
                Literal1.Text = "<table>\n";
                Literal1.Text += "<tr>\n";
                Literal1.Text += "<th>序号</th>\n";
                Literal1.Text += "<th>标题</th>\n";
                Literal1.Text += "<th>内容</th>\n";
                Literal1.Text += "<th>发布时间</th>\n";
                Literal1.Text += "<th>作者</th>\n";
                Literal1.Text += "<th>查看次数</th>\n";
                Literal1.Text += "<th>分类</th>\n";
                Literal1.Text += "</tr>\n";
                foreach (var data in InfoDao.FindAll()) {
                    Literal1.Text += "<tr>\n";
                    Literal1.Text += "<td>"+data.Id+"</td>\n";
                    Literal1.Text += "<td>"+data.Title+"</td>\n";
                    Literal1.Text += "<td>"+data.Content+"</td>\n";
                    Literal1.Text += "<td>"+data.PublishTime+"</td>\n";
                    Literal1.Text += "<td>"+data.Author+"</td>\n";
                    Literal1.Text += "<td>"+data.ClickNumber+"</td>\n";
                    Literal1.Text += "<td>"+data.CategoryMark+"</td>\n";
                    Literal1.Text += "</tr>\n";
                }
                Literal1.Text += "</table>\n";
            } catch(Exception){
                Literal1.Text = "数据加载异常！";
            }

        }
    }
}